/*
       udp client
*/

#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>

int main(int argc, char *argv[])
{
	struct sockaddr_in servaddr;
	int sockfd = 0;

	sockfd = socket(AF_INET, SOCK_DGRAM, 0);

	servaddr.sin_family = AF_INET;
#if 0
	servaddr.sin_port = htons(atoi(argv[2]));
	inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
#else
	servaddr.sin_port = htons(atoi(argv[1]));
	servaddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
#endif
	int on = 1;
    int ret2 = setsockopt(sockfd,SOL_SOCKET,SO_BROADCAST,&on,sizeof(on));
    while(on++ < 10)
	    ret2 = sendto(sockfd, "1", 1, 0, &servaddr, sizeof(servaddr));

	return(0);
}
